﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Xml;
using SmartMD.DataAccess.Service;
using SmartMD.DataModel.Entity;
using SmartMD.Manager.Utils;

namespace SmartMD.Manager.Specimens
{
    /// <summary>
    /// Interaction logic for LocateSpecDialog.xaml
    /// </summary>
    public partial class LocateSpecDialog : Window
    {
        private SpecQueryResult _queryResult;
        public LocateSpecDialog(SpecQueryResult result)
        {
            InitializeComponent();

            _queryResult = result;
            ShowSpecSite();
        }

        public void ShowSpecSite()
        {
            if (_queryResult != null)
            {               
                string sitecode = _queryResult.SiteCode;
               ContainerModelEntity modelEntity = DataServiceManager.ContainerService.GetContainerModel(sitecode);
               XmlDocument doc = new XmlDocument();
               if (modelEntity.StyleFile != null)
               {
                   doc.LoadXml(CompressionHelper.DeCompressToString(modelEntity.StyleFile));
                   this.CM.ShowCmwById(doc, sitecode);
               }
            }           
        }
    }
}
